<!DOCTYPE html>
<html lang="zh-CN"><head>
<title>消息列表</title>
<meta charset="utf-8">
<meta content="" name="description">
<meta content="" name="keywords">
<meta content="eric.wu" name="author">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
<meta content="no-cache" http-equiv="pragma">
<meta content="0" http-equiv="expires">
<meta content="telephone=no, address=no" name="format-detection">
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
<link rel="stylesheet" type="text/css" href="/sources/css/main.css">
<link rel="stylesheet" type="text/css" href="/sources/css/dialog.css">
<script src="/sources/js/jquery_min.js"></script>
<script src="/sources/js/main.js"></script>
<script src="/sources/js/helper_min.js"></script>
<script src="/sources/js/dialog_min.js"></script>
<script>
    function editNickName(thi, evt, sid , uid){
        var d = new iDialog();
        d.open({
            classList: "default",
            title:"",
            close:"",
            content:'<form id="form_1" action="javascript:;" method="post">\
                <table class="table_input">\
                    <tr>\
                        <td>\
                            <input type="text" maxlength="10" name="nickName" class="input" value="'+thi.getAttribute('data-nickname')+'" autofocus="true" />\
                        </td>\
                    </tr>\
                </table>\
            </form>',
            btns:[
                {id:"", name:"确定", onclick:"fn.call();", fn: function(self){
                    var form1 = document.getElementById("form_1");
                    var obj = {
                            sid : sid,
                            uid : uid,
                        nickName: $.trim(form1.nickName.value)
                    }
                    if(obj.nickName.length<1){
                        alert("请输入用户名", 1500);
                        return;
                    }
                    loading(true);
                    $.ajax({
                        url: "/snsmobile/ajaxeditnickname",
                        type:"post",
                        data:obj,
                        dataType:"JSON",
                        success: function(res){
                            loading(false);
                            if(1 == res.result){
                                self.die();
                                alert("修改成功", 1500);
                                $("#nickName label").html(obj.nickName);
                                $("#nickName a").attr("data-nickname", obj.nickName);
                            }else{
                                alert("修改失败", 1500);
                            }
                        }
                    });
                }},
                {id:"", name:"取消", onclick:"fn.call();", fn: function(self){
                    self.die();
                }}
            ]
        });
    }


    

    function showOperate(type, thi, evt){
        var pop_operate = document.getElementById("pop_operate");
        if(type){
            var btns = thi.innerHTML;
            pop_operate.querySelectorAll("div.pop_container")[0].innerHTML = btns;
            pop_operate.classList.add("on");
        }else{
            pop_operate.classList.remove("on");
        }
    }
    function commentPraise(thi,type,sid,tid,cid,uid) {
         var args = arguments;
         var li_id = thi.getAttribute("data-id");
         $li = $("#"+li_id);
         loading(true);
         $.post('/snsmobile/commentpraise',{
             "type" : type,
             "sid"  : sid,
             "tid"  : tid,
             "cid"  : cid,
             "uid"  : uid,
         },function(res){
             loading(false);
             if("1" == res){
                 $li.find("a").eq(1).attr("onclick", 'commentPraise(this, '+[1,0][type]+","+(Array.prototype.slice.call(args, 2).join(','))+');')[0].innerText = ["取消赞", "赞"][type];
             }
         });        
    }
</script>
</head>
    <body onselectstart="return true;" ondragstart="return false;" class="discuss_my discuss_my_xiaoxi">
        <div id="container" class="container">
            <header>
                <div class="header_1">
                    <ul class="tbox">
                        <li>
                            <span id="upload_header" class="head_img">
                                <img src="{$user_info.user_pic}">
                            </span>
                        </li>
                        <li>
                            <h5 id="nickName"><label>{$user_info.nick}</label><a href="javascript:void(0);" onclick="editNickName(this,2,3,4)" class="icons icons_edit">&nbsp;</a></h5>
                            <!--  
                            <p>
                                <a href="/Webnewmembercard/GetMember?pid=349257&wechatid=okthVt76nHZp7-wt88ED7szslHvw" class="label">
                                <span class="icons icons_vip_0">&nbsp;</span>非会员</a>
                            </p>
                            -->
                        </li>
                    </ul>
                </div>
                <div class="header_2">
                    <nav>
                        <ul class="box">
                            <li>
                                <a href="{$site_info.route_base}/index/trendslist?app_id={$site_info.app_id}&uid={$user_info.user_id}">
                                    <label>帖子</label>
                                    <span>{$user_info.post_count}</span>
                                </a>
                            </li>
                            <li>
                                <a href="{$site_info.route_base}/index/collectlist?app_id={$site_info.app_id}&uid={$user_info.user_id}">
                                    <label>喜欢</label>
                                    <span>{$user_info.like}</span>
                                </a>
                            </li>
                            <li>
                                <a href="javascript::void(0);" class="on">
                                    <label>消息</label>
                                    <span>{$user_info.comment_count}</span>
                                </a>
                            </li>
                        </ul>
                    </nav>
                </div>
            </header>
            <div class="body">
                <div id="list_article" class="list_article list_message">
                    <article>
                        <header>
                            <ul class="tbox">
                                <li>
                                    <a href="http://349257.m.weimob.com/snsmobile/othertrendslist?sid=349257&amp;uid=387016&amp;ruid=387016" class="head_img">
                                        <img src="/sources/pic/2.png" onerror="this.src='http://stc.weimob.com/img/sns/2.png';">
                                    </a>
                                </li>
                                <li>
                                    <h5>游客</h5>
                                    <p>2014-10-26 22:39:44</p>
                                </li>
                                <li id="r_cid_4570">
                                    <span class="icons icons_op" onclick="showOperate(true, this, event);">
                                        <a href="http://349257.m.weimob.com/snsmobile/commentview?sid=349257&amp;tid=3533&amp;cid=4570&amp;uid=387016&amp;exa_praise=0&amp;ruid=387016&amp;t=1" class="btn">回复</a>
                                        <a href="javascript:;" onclick="commentPraise(this, 0,349257,3533,4570,387016);" data-id="r_cid_4570" class="btn">赞</a>
                                        <a href="javascript:showOperate(false);" class="btn calcel">取消</a>
                                    </span>
                                </li>
                            </ul>
                        </header>
                        <section>
                            <div>
                                <div>高端机不错</div>
                            </div>
                        </section>
                        <div class="message">
                            <label>回复了我的评论：</label>联想的也不错
                        </div>
                    </article>
                    <article>
                        <header>
                            <ul class="tbox">
                                <li>
                                    <a href="http://349257.m.weimob.com/snsmobile/othertrendslist?sid=349257&amp;uid=387016&amp;ruid=387016" class="head_img">
                                    <img src="/sources/pic/2.png" onerror="this.src='http://stc.weimob.com/img/sns/2.png';">
                                    </a>
                                </li>
                                <li>
                                    <h5>游客</h5>
                                    <p>2014-10-26 22:38:54</p>
                                </li>
                                <li id="r_cid_4569">
                                    <span class="icons icons_op" onclick="showOperate(true, this, event);">
                                        <a href="http://349257.m.weimob.com/snsmobile/commentview?sid=349257&amp;tid=3533&amp;cid=4569&amp;uid=387016&amp;exa_praise=0&amp;ruid=387016&amp;t=1" class="btn">回复</a>
                                        <a href="javascript:;" onclick="commentPraise(this, 1,349257,3533,4569,387016);" data-id="r_cid_4569" class="btn">取消赞</a>
                                        <a href="javascript:showOperate(false);" class="btn calcel">取消</a>
                                    </span>
                                </li>
                            </ul>
                        </header>
                        <section>
                            <div>
                                <div>联想的也不错</div>
                            </div>
                        </section>
                        <div class="message">
                            <label>回复了我的评论：</label>我觉得苹果的，华硕的不错
                        </div>
                    </article>
                    <article>
                        <header>
                            <ul class="tbox">
                                <li>
                                    <a href="http://349257.m.weimob.com/snsmobile/othertrendslist?sid=349257&amp;uid=387016&amp;ruid=387016" class="head_img">
                                        <img src="/sources/pic/2.png" onerror="this.src='http://stc.weimob.com/img/sns/2.png';">
                                    </a>
                                </li>
                                <li>
                                    <h5>游客</h5>
                                    <p>2014-10-26 22:24:21</p>
                                </li>
                            </ul>
                        </header>
                        <section>
                            <div>
                                <h5>赞了你的帖子<a href="javascript:;" class="icons icons_like">&nbsp;</a></h5>
                            </div>
                        </section>
                        <div class="message">美工用的，整体性能稳定，分辩率高些。</div>
                    </article>
                    <article>
                        <header>
                            <ul class="tbox">
                                <li>
                                    <a href="http://349257.m.weimob.com/snsmobile/othertrendslist?sid=349257&amp;uid=387017&amp;ruid=387016" class="head_img">
                                        <img src="/sources/pic/2.png" onerror="this.src='http://stc.weimob.com/img/sns/2.png';">
                                    </a>
                                </li>
                                <li>
                                    <h5>游客</h5>
                                    <p>2014-10-26 22:20:14</p>
                                </li>
                            </ul>
                        </header>
                        <section>
                            <div>
                                <h5>赞了你的帖子<a href="javascript:;" class="icons icons_like">&nbsp;</a></h5>
                            </div>
                        </section>
                        <div class="message">美工用的，整体性能稳定，分辩率高些。</div>
                    </article>
                </div>
            </div>
            <footer>
                <section class="nav_footer">
                <ul class="box">
                    <li>
                        <a href="{$site_info.route_base}/index/index">
                            <span class="icons_home">&nbsp;</span>
                            <label>首页</label>
                        </a>
                    </li>
                    <li>
                        <a href="{$site_info.route_base}/index/newtrends/user_id/{$user_info.user_id}" class="nav_add">
                            <span class="icons_home_edit">&nbsp;</span>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:;" class="on">
                            <span class="icons_my">&nbsp;</span>
                            <label>我的</label>
                        </a>
                    </li>
                </ul>
                </section>
            </footer>
        </div>
    
    <section id="pop_operate" class="pop_operate">
        <div class="pop_container" onclick="showOperate(false);">
            <a href="javascript:;" class="btn">回复</a>
            <a href="javascript:;" class="btn">赞</a>
            <a href="javascript:showOperate(false);" class="btn calcel">取消</a>
        </div>
        <div class="pop_masker"></div>
    </section>
    <script>
        document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        WeixinJSBridge.call('hideOptionMenu');
    });
    </script>
<script type="text/javascript">  
$(document).ready(function(){
    var range = 50;             //距下边界长度/单位px  
    var pageNum = 2;  
    var totalheight = 0;   
    var main = $("#list_article");                //主体元素
    var state = 0;  
    var _srollPos = 0;

    var TPL = '   <article>'+
            '           <header>'+
            '               <ul class="tbox">'+
            '                   <li>'+
            '                       <a href="{his_tiezi_href}" class="head_img">'+
            '                           <img src="{r_head_img}" onerror="this.src=\'http://stc.weimob.com/img/sns/2.png\';" />'+
            '                       </a>'+
            '                   </li>'+
            '                   <li>'+
            '                       <h5>{nickName}</h5>'+
            '                       <p>{ctime}</p>'+
            '                   </li>{TPL_btns}</ul>'+
            '           </header>'+
            '           <section>'+
            '               <div>{content}</div>'+
            '           </section>'+
            '           <div class="message">{content2}</div>'+
            '       </article>';
    
    $(window).scroll(function(){
        var srollPos = $(window).scrollTop();    //滚动条距顶部距离(页面超出窗口的高度)  
        if(srollPos<_srollPos){
            return;
        }else{
            _srollPos = srollPos;
        }
        totalheight = parseFloat($(window).height()) + parseFloat(srollPos);  
        if(!state && (($(document).height()-range) <= totalheight) ) {
            loading(true);
            state = 1;
            $.post('/snsmobile/ajaxmessagelist',{
                "sid"  : 349257,
                "uid"  : 387016,
                "page" : pageNum
                },function(res){
                    loading(false);
                    if(res) {
                        var data = $.parseJSON(res);
                        html = iTemplate.makeList(TPL, data.rows, function(k,v){
                            var innerFlag = false;
                            var content2 = ''; 
                            var obj = {
                                his_tiezi_href:'/snsmobile/othertrendslist?sid='+v.sid+'&uid='+v.ruid+'&ruid='+data.uid,
                                r_head_img:(function(){
                                    switch(true){
                                        case ("2" == v.wechat && "3" == v.type):
                                            innerFlag = true;
                                            return v.r_head_img;
                                        break;
                                        default :
                                            return v.head_img;
                                        break;
                                   }    
                                })(),
                                ctime:(function(vctime){
                                    var f_ctime = new Date(vctime);
                                    var arr = [];
                                    arr.push( f_ctime.getFullYear() );
                                    arr.push( "-" + (f_ctime.getMonth()+1 ) );
                                    arr.push( "-" + f_ctime.getDate() );
                                    arr.push( " " + f_ctime.getHours() );
                                    arr.push( ":" + f_ctime.getMinutes() );
                                    arr.push( ":" + f_ctime.getSeconds() );
                                    return arr.join("");
                                })(v.ctime*1000),
                                content: (function(){
                                    switch(v.type){
                                        case "1":
                                            content2 = v.trends;
                                            return '<h5>赞了你的帖子<a href="javascript:;" class="icons icons_like">&nbsp;</a></h5>';
                                      break;
                                        case "2":
                                            content2 = '<label>评论了我的帖子：</label>'+v.trends;
                                            return '<div>'+v.comment+'&nbsp;</div>';
                                        break;
                                        case "3":
                                            content2 = '<label>回复了我的评论：</label>'+v.c_comment;
                                            return '<div>'+v.r_comment+'</div>';
                                            break;
                                        case "4":
                                            content2 = v.comment;
                                            return '<h5>赞了你的评论<a href="javascript:;" class="icons icons_like">&nbsp;</a></h5>';
                                            break;
                                        default:
                                            return "";
                                            break;
                                    }
                                })(),
                                content2: content2,
                                TPL_btns : ("2" == v.type || "3" == v.type)?(function(){
                                    v.ispraise = parseInt(v.ispraise);
                                    console.log(v.ispraise);
                                    if("2" == v.type){
                                        return '<li id="r_cid_'+v.cid+'">\
                                            <span class="icons icons_op" onclick="showOperate(true, this, event);">\
                                                <a href="/snsmobile/commentview?sid='+v.sid+'&tid='+v.tid+'&cid='+v.cid+'&uid='+v.ruid+'&exa_praise='+data.exa_praise+'&ruid='+data.uid+'&t=1" class="btn">回复</a>\
                                                <a href="javascript:;" onclick="commentPraise(this, '+(v.ispraise?1:0)+','+v.sid+','+v.tid+','+v.cid+','+data.uid+');" data-id="r_cid_'+v.cid+'" class="btn">'+(v.ispraise?'取消赞':'赞')+'</a>\
                                                <a href="javascript:showOperate(false);" class="btn calcel">取消</a>\
                                            </span>\
                                        </li>';
                                   }else{
                                       return '<li id="r_cid_'+v.r_cid+'">\
                                        <span class="icons icons_op" onclick="showOperate(true, this, event);">\
                                            <a href="/snsmobile/commentview?sid='+v.sid+'&tid='+v.tid+'&cid='+v.r_cid+'&uid='+v.ruid+'&exa_praise='+data.exa_praise+'&ruid='+data.uid+'&t=1" class="btn">回复</a>\
                                            <a href="javascript:;" onclick="commentPraise(this, '+(v.ispraise?1:0)+','+v.sid+','+v.tid+','+v.r_cid+','+data.uid+');" data-id="r_cid_'+v.r_cid+'" class="btn">'+(v.ispraise?'取消赞':'赞')+'</a>\
                                            <a href="javascript:showOperate(false);" class="btn calcel">取消</a>\
                                        </span>\
                                    </li>';
                                   }
                                })():''
                            }

                            obj.nickName = (innerFlag? v.r_nickname:v.nickname)||'游客';
                            return obj;
                        });
                        main.append($(html) );
                        pageNum ++;
                        state = 0;
                    }else{
                        loading(false);
                        state = 0;
                        alert("没有更多了","1500");
                    }
                });
        }
    });  
}); 
</script> 
</body>
</html>